#include <bits/stdc++.h>
#define LL long long
using namespace std;
int T, n, m, V, L, d[100005], v[100005], a[100005], p[100005], ans[100005], sum;
vector<int> vec[100005];
void solve() {
    memset(d, 0, sizeof(d));
    memset(v, 0, sizeof(v));
    memset(a, 0, sizeof(a));
    memset(p, 0, sizeof(p));
    memset(ans, 0, sizeof(ans));
    sum = 0;
    cin >> n >> m >> L >> V;
    for (int i = 0; i < n; i++) {
        cin >> d[i] >> v[i] >> a[i];
    }
    for (int i = 0; i < m; i++) {
        cin >> p[i];
    }
    for (int i = 0; i < m; i++) {
        for (int j = 0; j < n; j++) {
            //cout << v[j] << endl;
            if (p[i] - d[j] < 0) {
                continue;
            }
            double v_ = sqrt(double(v[j] * v[j]) + 2 * a[j] * (p[i] - d[j]));
            if (v_ > V) {
                // cout << j << ' ' << v_ << endl;
                vec[i].push_back(j);
                ans[j] = 1;
            }
        }
    }
    for (int j = 0; j < n; j++) {
        sum += ans[j];
    }
    int result = 0;
    for (int i = 0; i < m; i++) {
        int s = 0, res[100005];
        memset(res, 0, sizeof(res));
        for (int j = 0; j < m; j++) {
            if (j == 1) {
                continue;
            }
            for (int k = 0; k < vec[j].size(); k++) {
                res[vec[j][k]] = 1;
            }
        }
        for (int j = 0; j < n; j++) {
            s += res[j];
        }
        if (s == sum) {
            vec[i].clear();
            result++;
        }
    }
    cout << sum << ' ' << result;
    //for (int i = 0; i < n; i++) {
    //    cout << d[i] << ' ' << v[i] << ' ' << a[i] << endl;
    //}
    //for (int i = 0; i < m; i++) {
    //   cout << p[i] << ' ';
    //}
    cout << endl;
}
int main()
{
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    cin >> T;
    while (T--) {
        solve();
    }
    return 0;
}
